package logic

import (
	"context"
	"house/houserpc/houserpcclient"

	"house/api/internal/svc"
	"house/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerfectLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerfectLogic {
	return &PerfectLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PerfectLogic) Perfect(req *types.PerfectRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	perfect, err := l.svcCtx.HouseRpc.UserPerfect(l.ctx, &houserpcclient.UserPerfectRequest{
		UserId:   req.UserId,
		Account:  req.Account,
		Password: req.Password,
		Image:    req.Image,
		Name:     req.Name,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "信息完善成功",
		Code:    200,
		Data:    perfect,
	}, nil
}
